<!--
 * @Author: HeAo
 * @Date: 2021-10-20 11:25:07
 * @LastEditTime: 2021-10-20 11:57:09
 * @LastEditors: HeAo
 * @Description: 
 * @FilePath: \vue-admin-template\src\views\category\index.vue
 * 别乱动！
-->
<template>
  <div class="category">
    <h3>栏目管理</h3>
    {{ categories }}
    <el-table :data="categories" style="width: 100%">
      <el-table-column type="index" label="序号"></el-table-column>
      <!-- <el-table-column prop="id" label="栏目编号"></el-table-column> -->
      <el-table-column prop="name" label="栏目名称"></el-table-column>
      <el-table-column label="操作">
        <template v-slot="scope">
          <el-button @click="toDeleteHandler(scope.row.id)" type="text"
            >删除</el-button
          >
          <el-button @click="toEditHandler(scope.row)" type="text"
            >修改</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import { mapState, mapActions } from "vuex";
export default {
  data() {
    return {};
  },
  computed: {
    ...mapState("category", ["categories"]),
  },
  methods: {
    ...mapActions("category", ["findAllCategories"]),
    // 删除按钮点击处理程序
    toDeleteHandler(id) {
      this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        console.log(id);
      });
    },
    // 删除按钮点击处理程序
    toEditHandler(row) {
      console.log(row);
    },
  },
  created() {
    this.findAllCategories();
  },
};
</script>
<style scoped>
</style>
